package com.guigu.www.denghao.controller;

import com.guigu.www.denghao.service.DHRubricService;
import com.guigu.www.pojo.PageVo;
import com.guigu.www.pojo.Question;
import com.guigu.www.pojo.Rubric;
import com.guigu.www.pojo.RubricOption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/DHRubricController")
public class DHRubricController {

    @Autowired
    private DHRubricService dhRubricService;

    @PostMapping("/initRub")
    public PageVo<Rubric> initRub(Integer pageNum,Integer pageSize,String rubName,String rubType){
        return dhRubricService.initRub(pageNum,pageSize,rubName,rubType);
    }

    @PostMapping("/addRub")
    public Integer addRub(@RequestBody Rubric rubric){
        return dhRubricService.addRub(rubric);
    }

    @PostMapping("/watchRub/{rubId}")
    public List<RubricOption> watchRub(@PathVariable Integer rubId){
        return dhRubricService.watchRub(rubId);
    }

    @PostMapping("/delRub")
    public Integer delRub(Integer rubId, Integer rubState){
        return dhRubricService.delRub(rubId,rubState);
    }

    @PostMapping("/queryByIdRubric")
    public Rubric queryByIdRubric(Integer rubId){
        return dhRubricService.queryByIdRubric(rubId);
    }

    @PutMapping("/upRub")
    public Integer upRub(@RequestBody Rubric rubric){
        return dhRubricService.upRub(rubric);
    }
}
